package main

import (
    "fmt"
    "time"
)

func printNumber(i int, ch chan int) {
    <-ch
    fmt.Println(i)
    time.Sleep(time.Millisecond * 500) // 模拟一些执行时间
    if i < 9 {
        ch <- i + 1
    }
}

func main() {
    ch := make(chan int, 1)
    ch <- 0

    for i := 0; i < 10; i++ {
        go printNumber(i, ch)
    }

    time.Sleep(time.Second * 10)
}